<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script>
            function f1(){

                var arr=new Array();


                // alert(typeof  arr);


                arr[0]=1;
                arr[1]=2;
                arr[2]="aaa";

                console.log(arr);

                console.log(arr.length);

                arr[3]="bbb";

                console.log(arr.length);

                var arr2=[1,2,3,"abc"];//json语法

                for(var i=0;i<arr2.length;i++){
                    console.log(arr2[i]);
                }

                var arr3=new Array();
                arr3[0]=[1,2,3];
                arr3[1]=[4,5];

                for(var i=0;i<arr3.length;i++){
                    for(var j=0;j<arr3[i].length;j++){
                        console.log(arr3[i][j]);
                    }
                }


            }


            function f2(){
                var arr=[123,233,55,44,2222];


                console.log(arr.sort());

                var fn=function(a,b){
                    return a-b;
                };


                console.log(arr.sort(fn));

                console.log(arr.sort(function(a,b){
                    return b-a;
                }));


            }

            function f3(){
                var arr1=[1,2,3];
                var arr2=[4,5];

                var arr3=arr1.concat(arr2);

                console.log(arr1);
                console.log(arr2);
                console.log(arr3);

                var str1=arr3.join();

                console.log(str1);

                console.log(arr3.join("-"));

                console.log(arr3.join("abc"));


                var stack=new Array();

                stack.push("aaa");
                stack.push("bbb");
                stack.push("ccc");
                stack.push("ddd");

                console.log(stack.pop());
                console.log(stack.pop());
                console.log(stack.pop());
                console.log(stack.pop());

                console.log(arr3.reverse());


                console.log(arr3.slice(2));
                console.log(arr3.slice(1,3));
            }
        </script>
    </head>
    <body>
        <a href="javascript:;" onclick="f1();">test1</a>
        <a href="javascript:;" onclick="f2();">test2</a>
        <a href="javascript:;" onclick="f3();">test3</a>
    </body>
</html>